package br.com.jf.componentes;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class AccordionPanelTag extends BodyTagSupport{
	
	private String idAccordion;
	
	@Override
	public int doEndTag() throws JspException {

		JspWriter writer = pageContext.getOut();
		
		StringBuilder conteudoSaida = new StringBuilder();
				
		
		conteudoSaida.append("<div id='"+ idAccordion +"'>");
		conteudoSaida.append(getBodyContent().getString());
		conteudoSaida.append("</div>");
		
		
		conteudoSaida.append("<script type='text/javascript'>");
		conteudoSaida.append("$('#"+ idAccordion +"').accordion()");
		conteudoSaida.append("</script>");
		
		try {
		
			writer.write(conteudoSaida.toString());
		
		} catch (IOException e) {
			e.printStackTrace();
		}
	
		
		return super.doEndTag();
	}

	public String getIdAccordion() {
		return idAccordion;
	}

	public void setIdAccordion(String idAccordion) {
		this.idAccordion = idAccordion;
	}
	
}
